cmd_sf: let "sf update" erase last sector as a whole
authorGerlando Falauto <[email protected]>
Wed, 3 Jul 2013 18:33:57 +0000 (20:33 +0200)
committerJagannadha Sutradharudu Teki <[email protected]>
Tue, 6 Aug 2013 19:35:07 +0000 (01:05 +0530)
make "sf update" work with unaligned `len' parameter, by deleting the
whole last sector before writing, so to allow for:

 sf update ${load_addr_r} 0 ${filesize}

Signed-off-by: Gerlando Falauto <[email protected]>
Cc: Valentin Longchamp <[email protected]>
Cc: Holger Brunck <[email protected]>
Acked-by: Simon Glass <[email protected]>
Reviewed-by: Jagannadha Sutradharudu Teki <[email protected]>
common/cmd_sf.c

index 34844ac4a0b5cfb85cb053bac6ac5ea527c66d81..4af0f0af26bcfa3afbc63708fb019a89cc99d274 100644 (file)
@@ -160,7 +160,8 @@ static const char *spi_flash_update_block(struct spi_flash *flash, u32 offset,
                *skipped += len;
                return NULL;
        }
-       if (spi_flash_erase(flash, offset, len))
+       /* Erase the entire sector */
+       if (spi_flash_erase(flash, offset, flash->sector_size))
                return "erase";
        if (spi_flash_write(flash, offset, len, buf))
                return "write";